
from django.contrib import admin
from django.urls import include
from django.urls import path
from django.urls import re_path
from rest_framework.routers import SimpleRouter, DefaultRouter

from books.views import *

urlpatterns = [
    path('admin/', admin.site.urls),
]

# 实例化路由对象
router = DefaultRouter()
# 指定映射规则:prefix->前缀， viewset ->要映射的视图， base_name :其别名用于路由反解析
router.register(prefix="books", viewset=BookView, base_name="books")
router.register(prefix="heros", viewset=HerosView, base_name="heros")
#router.urls :得到的是路由列表 [repath(),repath(),....]
#路由列表的合并：extend
urlpatterns.extend(router.urls)
